package com.lefevre.cms.bean.help;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 帮助分类
 *
 * @author Lefevre
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("help_type")
@Entity
@Table(name = "help_type", indexes = {@Index(name = "helpType_1_idx", columnList = "parentId"), @Index(name = "helpType_2_idx", columnList = "parentIdGroup")})
public class HelpType implements Serializable {
    private static final long serialVersionUID = 2998010027677137673L;

    @Id
    @TableId(type = IdType.INPUT)
    private Long id;

    /**
     * 类别名称
     **/
    @Column(length = 200)
    @TableField("`name`")
    private String name;

    /**
     * 所属父类ID
     **/
    @TableField("parentId")
    private Long parentId = 0L;

    /**
     * 排序
     **/
    @TableField("sort")
    private Integer sort = 0;

    /**
     * 子节点数量
     **/
    @TableField("childNodeNumber")
    private Integer childNodeNumber = 0;

    /**
     * 父Id组
     **/
    @Column(length = 200)
    @TableField("parentIdGroup")
    private String parentIdGroup = ",0,";

    /**
     * 帮助总数量(显示+回收站)
     **/
    @TableField("totalHelp")
    private Long totalHelp = 0L;

    /**
     * 帮助数量(显示)
     **/
    @TableField("helpQuantity")
    private Long helpQuantity = 0L;

    /**
     * 已合并分类Id
     **/
    @Column(length = 1000)
    @TableField("mergerTypeId")
    private String mergerTypeId = ",";

    /**
     * 图片
     **/
    @Column(length = 100)
    @TableField("`image`")
    private String image;

    /**
     * 描述
     **/
    @Lob
    @TableField("`description`")
    private String description;

    /**
     * 子节点帮助分类
     **/
    @Transient
    @TableField(exist = false)
    private List<HelpType> childHelpType = new ArrayList<>();

    public HelpType(String name) {
        this.name = name;
    }

}
